home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / FileBuf.h < prev    next >
C/C++ Source or Header  |  1992-05-08  |  880b  |  40 lines

  1. #ifndef Filebuf_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define Filebuf_First
  7.  
  8. #include "StreamBuf.h"
  9.  
  10. enum open_mode { input= 0, output= 1, append= 2 };
  11.  
  12. //---- Filebuf -----------------------------------------------------------------
  13.  
  14. class Filebuf : public StreamBuf {     // a Stream buffer for files
  15.     int fd;         // file descriptor
  16.     bool opened;    // non-zero if file has been opened
  17.     bool mapped;
  18.  
  19. public:
  20.     Filebuf();
  21.     Filebuf(int nfd);
  22.     Filebuf(int nfd, char* p, int l);
  23.     Filebuf(char *path, open_mode m);
  24.  
  25.     ~Filebuf();
  26.     
  27.     bool isopen()
  28.     { return opened; }
  29.  
  30.     // Open a file. return 0 if failure; return "this" if success
  31.     Filebuf* open(char *name, open_mode om);
  32.     
  33.     bool close();
  34.     int Overflow(u_char *bp, int size);
  35.     int Underflow(u_char *p, int l);
  36.     long Seek(long pos, int whence);
  37. };
  38.  
  39. #endif
  40.